/**
 * @(#) SubjectCategoryWiseStudentListController.java
 * Copyright (c) 2011 EdRP, Dayalbagh Educational Institute.
 * All Rights Reserved.
 *
 * Redistribution and use in source and binary forms, with or
 * without modification, are permitted provided that the following
 * conditions are met:
 *
 * Redistributions of source code must retain the above copyright
 * notice, this  list of conditions and the following disclaimer.
 *
 * Redistribution in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in
 * the documentation and/or other materials provided with the
 * distribution.
 *
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL ETRG OR ITS CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL,SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * Contributors: Members of EdRP, Dayalbagh Educational Institute
 */
package in.ac.dei.edrp.cms.controller.reportgeneration;
import in.ac.dei.edrp.cms.dao.reportgeneration.FinalSemesterResultStatisticsDAO;
import in.ac.dei.edrp.cms.domain.reportgeneration.FinalSemesterResultStatistics;
import in.ac.dei.edrp.cms.domain.reportgeneration.SubjectWiseMeritList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

/**
 * This controller is designed for setting & retrieving
 * the activity master information 
 * @author Ankit Jain
 * @date 15 Apr 2011
 * @version 1.0
 */
public class FinalSemesterResultStatisticsController extends MultiActionController{

	private FinalSemesterResultStatisticsDAO finalSemesterResultStatisticsDAO;
	
	public void setFinalSemesterResultStatisticsDAO(
			FinalSemesterResultStatisticsDAO finalSemesterResultStatisticsDAO) {
		this.finalSemesterResultStatisticsDAO = finalSemesterResultStatisticsDAO;
	}

	/**
     * Method to get the program list
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
	public ModelAndView getSessionList(HttpServletRequest request,
			HttpServletResponse response)throws Exception {
		FinalSemesterResultStatistics finalSemesterResultStatistics=new FinalSemesterResultStatistics();
		
		finalSemesterResultStatistics.setEntityId(request.getParameter("selectedEntityId"));
		finalSemesterResultStatistics.setUniversityId(request.getParameter("selectedEntityId").substring(0, 4));
		
		System.out.println(finalSemesterResultStatistics.getUniversityId());
		
		List<FinalSemesterResultStatistics> sessionDatesList = finalSemesterResultStatisticsDAO.getSessionList(finalSemesterResultStatistics);
		return new ModelAndView("SubjectCategoryWiseStudentList/SessionDates","sessionDates", sessionDatesList);
			
	}
	
	/**
     * this method will get the current session
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
	public ModelAndView getCurrentSession(HttpServletRequest request,
			HttpServletResponse response)throws Exception {
		SubjectWiseMeritList subjectWiseMeritList=new SubjectWiseMeritList();
		subjectWiseMeritList.setUniversityId(request.getParameter("selectedEntityId").substring(0, 4));
		List<SubjectWiseMeritList> sessionDates = finalSemesterResultStatisticsDAO.getCurrentSession(subjectWiseMeritList);
		return new ModelAndView("SubjectCategoryWiseStudentList/SessionDates","sessionDates", sessionDates);			
	}
	
	
	/**
     * Method for generate the PDF.
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
	public ModelAndView generatePDF(HttpServletRequest request,
			HttpServletResponse response)throws Exception {
		
		System.out.println("inside generatePDF merit list controller");
		
		FinalSemesterResultStatistics finalSemesterResultStatistics=new FinalSemesterResultStatistics();
		finalSemesterResultStatistics.setEntityId(request.getParameter("selectedEntityId"));
		finalSemesterResultStatistics.setSessionStartDate(request.getParameter("sessionStartDate"));
		finalSemesterResultStatistics.setSessionEndDate(request.getParameter("sessionEndDate"));
		
		System.out.println("entityId is: "+ finalSemesterResultStatistics.getEntityId());
		System.out.println("semesterStartDate is: "+ finalSemesterResultStatistics.getSessionStartDate());
		System.out.println("SemesterEndDate is: "+ finalSemesterResultStatistics.getSessionEndDate());
		
		List <FinalSemesterResultStatistics> getProgramDetail = finalSemesterResultStatisticsDAO.getProgramDetails(finalSemesterResultStatistics);
		System.out.println("siiiiize is:"+ getProgramDetail.size());
		return new ModelAndView("finalSemesterResultStatisticsPDFView","getProgramDetail", getProgramDetail);		
	}
	
}